#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
inline LL read()
{
	LL x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=200;
int n,w[MAXN],c[MAXN],ans=INF,sum;
LL f[400010],m;
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;++i)w[i]=read();
	for(int i=1;i<=n;++i)c[i]=read();
	f[0]=1;
	if(m<=1)return puts("0"),0;
	for(int i=1;i<=n;++i)
	{
		if(w[i]==1)continue;
		sum+=w[i]*c[i];
		for(int j=min(ans,sum);j>=2*c[i];--j)
		{
			for(int k=2;k<=w[i]&&k*c[i]<=j;++k)
				if(f[j-c[i]*k]*k>f[j])f[j]=f[j-c[i]*k]*k;
			if(f[j]>=m)ans=j;
		}
	}
	printf("%d\n",ans);
	return 0;
}
